From: Marco Trevisan (TreviƱo) Date: Fri, 5 Dec 2025 22:39:23 +0000 (+0100) Subject: environment: Split out the prepare and cleanup animation code X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~55^2^2~13 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f7cfc7ff4a67a32363e57474bef4f95ecea3e0c3;p=gnome-shell.git environment: Split out the prepare and cleanup animation code We do the same twice, and it's not trivial code anymore, so let's separate this into another function which returns the prepare and cleanup functions Part-of: (cherry picked from commit 7aacc1cab033fd77370b8d03b037892b3dd28a7f) --- diff --git a/js/ui/environment.js b/js/ui/environment.js index b971ed8ae..1bd76374b 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -71,6 +71,19 @@ function _makeEaseCallback(params, cleanup) { }; } +function _makeEasePrepareAndCleanup() { + const prepare = () => { + global.compositor.disable_unredirect(); + global.begin_work(); + }; + const cleanup = () => { + global.compositor.enable_unredirect(); + global.end_work(); + }; + + return {prepare, cleanup}; +} + function _getPropertyTarget(actor, propName) { if (!propName.startsWith('@')) return [actor, propName]; @@ -128,15 +141,8 @@ function _easeActor(actor, params) { actor.set_easing_mode(params.mode); delete params.mode; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; - let callback = _makeEaseCallback(params, cleanup); + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); + const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transitions let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g')); @@ -209,15 +215,8 @@ function _easeAnimatableProperty(animatable, propName, target, params) { if (!actor?.mapped) duration = 0; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; - let callback = _makeEaseCallback(params, cleanup); + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); + const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transition animatable.remove_transition(propName);